<HTML><HEAD>
<!--
    --------------
    Marquee Random
    --------------
-->

<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers

/*
    THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
    Copyright (c)2000 by Charles River Media.  All Rights Reserved.
    
    This applet can only be re-used or modifed by license holders of the
    JavaScript Cookbook CD-ROM.  Credit must be given in the source
    code and this copyright notice must be maintained. If you do
    not hold a license to the JavaScript Cookbook, you may NOT
    duplicate or modify this code for your own use.

    Use at your own risk. No warranty is given or implied of the suitability 
    of this applet for any specific application. Neither Erica Sadun nor 
    Charles River Media will be held responsible for any unwanted effects 
    due to the use of this applet or any derivative. 
*/

var str=""
var direction="left"

/* create an array */
function createArray(n)
{
    for (var i = 0; i < n; i++) {this[i] = 0}
    return this
}

//------------------RANDOM NUMBERS----------------------------
var js_mult1=3141
var js_mult2=5821
var js_m1=100000000
var js_m2=10000
var js_iseed=0
var js_iseed1=0
var js_iseed2=0


// Return a Random Integer between 0 and N-1
function random(n)
{
    if (js_iseed == 0)
    {
        now = new Date()
        js_iseed = now.getHours() + now.getMinutes() * 60 
                    + now.getSeconds() * 3600
    }
    js_iseed1 = js_iseed / js_m2
    js_iseed2 = js_iseed % js_m2
    var tmp = (((js_iseed2 * js_mult1 + js_iseed1 * js_mult2) % js_m2) * 
                js_m2 + (js_iseed2 * js_mult2)) % js_m1
    js_iseed = (tmp + 1) % js_m1
    return (Math.floor((js_iseed/js_m1) * n))
}


//----------------Message Utilities------------------------

// Populate your message with any character except #
msgArray = createArray(5)
msgArray[0] = "To thine own self be true"
msgArray[1] = "Know then thyself"
msgArray[2] = "Accomplishment produces esteem"
msgArray[3] = "Virtue is doing what must be done"
msgArray[4] = "I'll think about it tomorrow"

msg = ""
dmsg = ""


// Create Status Bar Message
function doMessage()
{
    if (msg == dmsg) // reset and delay
    {
        // pick a message
        msg = msgArray[random(5)] 
        
        // populate dmsg with blanks
        dmsg = "" 
        for (var ii = 0; ii < msg.length; ii++) dmsg += " "
        
        // cause initial delay
        JSCTimeOutID = window.setTimeout('doMessage()',100)
        return true
    }
    
    // pick a character
    var ii = random(msg.length)
    
    // add it to the string
    var astr = dmsg.substring(0, ii)
    var bstr = msg.substring(ii, ii+1)
    var cstr = dmsg.substring(ii+1, dmsg.length)
    
    // update the screen string
    dmsg = astr+bstr+cstr
    window.status = dmsg
    
    // set the delay
    JSCTimeOutID = window.setTimeout('doMessage()',50)
    
    // we must return here because JavaScript insists that one
    // good return deserves another.  (See the msg == dmsg code
    // above to better understand the first "escape")
    return true
}

<!-- done hiding --></SCRIPT></HEAD>

<BODY bgcolor="ffffff" link="0000ff" vlink="770077"
onload="JSCTimeOutID = window.setTimeout('doMessage()',500);">
    
<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50
ALIGN = LEFT>Marquee #5: Random Messages</H1></FONT>

    <BLOCKQUOTE><FONT COLOR="770000">
        This script loads a random message one letter at a time--
        in random order.
    </FONT></BLOCKQUOTE>

    <BR><BR>
    
    <FONT COLOR="007777"><H2>Discussion</H2></FONT>
    <FONT SIZE=4>
        Like previous scripts, this JavaScript sets an initial
        timeout in the BODY that is renewed in a function call.
        This script makes extensive use of substrings as 
        a status-bar message is built up a character at a time.
    </FONT>        


<h5>Copyright &copy;1996 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>